const path = require('path')
// const htmlWebpackPlugin = require('html-webpack-plugin')
const webpack = require('webpack')
const theme = require('./package.json').theme

module.exports = {
    entry:{
        app :path.join(__dirname,'./src/main.js'),
        // vendor: ['react','react-dom']  // 把要抽离的第三方包名称 放在数组中
    },
    output:{
        path: path.join(__dirname, './dist'),
        filename: 'bundle.js'
    },
    resolve: {
        extensions: ['.jsx' , '.scss', '.css', '.json', '.js']
    },
    // 配置html在内存中
    // plugins: [
        // new webpack.optimize.CommonsChunkPlugin({
        //     name: 'vendor', // 指定要抽离的入口名称
        //     filename: 'vendors.js' // 发布之后的第三方包的名称
        // }),
    //     new htmlWebpackPlugin({
    //         template: path.join(__dirname, './src/index.html'),
    //         filename : 'index.html'
    //     })
    // ],
    devtool: "source-map", // 开启 sourceMap 功能，便于sass调试。
    module:{
       
        rules: [
            {test:/\.css$/, use: ['style-loader', 'css-loader']},
            {test:/\.scss$/,use: ['style-loader?sourceMap', 'css-loader?sourceMap', 'sass-loader?sourceMap']},
            {test:/\.(png|jpg|bmp|gif)$/,use: ['file-loader?name=[name].[ext]&outputPath=images']},
            {test:/\.jsx?$/,use: ['babel-loader'], exclude: /node_modules/ },
            {test:/\.(eot|svg|ttf|woff|woff2)$/,use:['url-loader?name=fonts/[name].[ext]']},
            {
                test: /\.less$/,
                use: [
                    'style-loader',
                    'css-loader',
                    {loader: 'less-loader', options: {modifyVars: theme}},
                ],
                include: /node_modules/,
            },
        ]
    },
    devServer: {
        // contentBase: path.resolve(__dirname, 'src'),
        // hot: false,
        // https: false,
        // proxy: [{
        //   context: ['/member/**', '/main/**', '/cp/**','/user/**','/rules/**'],
        //   target: 'http://192.168.5.126:8080/',
        //   secure: false,
        // }, {
        //   context: ['/Inter/**', '/flat/**', '/sport/**', '/electronic/**'],
        //   target: 'http://103.243.181.58:8890/',
        //   secure: false,
        // }],
      }
}